using System;
using System.Collections.Generic;

using Spring.Data.NHibernate.Generic;

using efish.Framework.Common;

namespace efish.Framework.Dao
{
    /// <summary>
    /// Summary description for DAOBase
    /// </summary>
    public abstract class BaseDAO<T> : HibernateTemplateEx
    {
        public BaseDAO()
        {
        }

        public virtual T Load(object id)
        {
            return this.Load<T>(id);
        }
        public virtual T Get(object id)
        {
            return this.Get<T>(id);
        }
        public virtual void Save(T obj)
        {
            this.Save(obj);
        }
        public virtual void Update(T obj)
        {
            this.Update(obj);
        }
        public virtual void Delete(T obj)
        {
            this.Delete(obj);
        }
        public virtual void DeleteByID(object id)
        {
            T transobj = this.Load(id);
            this.Delete(transobj);
        }
        public virtual IList<T> GetAll()
        {
            return this.LoadAll<T>();
        }
        public virtual int GetCount()
        {
            return this.LoadAll<T>().Count;
        }

        public virtual IPageList<T> GetAllByPage(int pageIndex, int count)
        {
            return this.LoadPageByType<T>(pageIndex, count);
        }
    }
}
